<style>
    .layui-form-label {
        width: 100px;
    }

    .layui-input-block {
        margin-left: 130px;
    }
</style>
<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding ">
        <div class=" rc-pannel layui-form">
            <div class=" rc-pannel-header rc-pagepadding rc-bold">
                <i class="iconfont goback rc-pointer">&#xe62b;</i> 添加积分规则
            </div>
            <div class="rc-pannel-body  rc-pagepadding">


                <div class="layui-form-item">
                    <label class="layui-form-label">规则名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" autocomplete="off" value="" lay-verify="required" class="layui-input" title="等级名称" />

                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">挂载钩子</label>
                    <div class="layui-input-block">
                        <input type="text" id="hookident" name="hookident" autocomplete="off" value="" lay-verify="required" class="layui-input" title="所需积分" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">增长/扣除</label>
                    <div class="layui-input-block">
                        <select name="addsub">
                            <option value="1">增加</option>
                            <option value="2">扣除</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">积分数</label>
                    <div class="layui-input-block">
                        <input type="text" name="integral" autocomplete="off" value="1" lay-verify="required" class="layui-input" title="所需积分" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">每日限额 <i class="layui-icon layui-icon-question rc-tips rc-pointer" message="每日每用户最多增长多少积分，0不限制"></i></label>
                    <div class="layui-input-block">
                        <input type="text" name="daylimit" autocomplete="off" value="0" lay-verify="required" class="layui-input" title="所需积分" />
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">总限额 <i class="layui-icon layui-icon-question rc-tips rc-pointer" message="整个系统内每用户最多增长多少积分，0不限制"></i></label>
                    <div class="layui-input-block">
                        <input type="text" name="alllimit" autocomplete="off" value="0" lay-verify="required" class="layui-input" title="所需积分" />
                    </div>
                </div>

                <div class="layui-form-item rc-margin-bottom0">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-submit lay-filter="submit">提交</button>
                        <button type="reset" class="layui-btn layui-btn-sm">重置</button>
                    </div>
                </div>

            </div>



        </div>

    </div>
</div>
<script src="/static/admin/lib/layui/modules/cascader/cascader.js"></script>
<script>
    layui.use(function() {

        var form = layui.form;
        var layCascader = layui.layCascader;

        var el_actions = '<?php echo $actions ?>';
        var el_actions_obj = $.parseJSON(el_actions);
        console.log(el_actions_obj);
        var el_cascader = layCascader({
            elem: '#hookident',
            filterable: true,
            options: el_actions_obj,
            props: {
                value: 'ident',
                label: 'title',
            }
        });


        form.on('submit(submit)', function(data) {
            $.ajax({
                url: '/admin/cnf/UserIntegralRule/add', //请求路径
                type: "POST", //请求方式
                data: data.field, // 默认写法
                success: function(data) {
                    if (data.code == 0) {
                        toastr_success("添加成功", function() {
                            window.location.href = '/admin/cnf/UserIntegralRule/index';
                        });
                    } else {
                        toastr_error(data.message);
                    }
                },
                error: function() {

                },

            });
        });



    });
</script>